package com.osgix.authorize.model;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.osgix.common.pojo.BaseEntity;
import com.osgix.common.utils.DateConvertUtils;

public class UserInfo extends BaseEntity implements java.io.Serializable {
	private static final long serialVersionUID = 5454155825314635342L;

	// alias
	public static final String TABLE_ALIAS = "UserInfo";
	public static final String ALIAS_USER_ID = "userId";
	public static final String ALIAS_LOGIN_ACCOUNT = "loginAccount";
	public static final String ALIAS_USER_NAME = "userName";
	public static final String ALIAS_FIRST_NAME = "firstName";
	public static final String ALIAS_LAST_NAME = "lastName";
	public static final String ALIAS_LOGIN_PWD = "loginPwd";
	public static final String ALIAS_LOGIN_EMAIL = "loginEmail";
	public static final String ALIAS_USER_TYPE = "userType";
	public static final String ALIAS_REGISTER_TIME = "registerTime";
	public static final String ALIAS_USER_STATUS = "userStatus";

	// date formats
	public static final String FORMAT_REGISTER_TIME = DATE_FORMAT;

	// 可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	// columns START

	private Long userId;
	@NotBlank
	@Length(max = 32)
	private java.lang.String loginAccount;
	@NotBlank
	@Length(max = 64)
	private java.lang.String userName;
	@Length(max = 32)
	private java.lang.String firstName;
	@Length(max = 32)
	private java.lang.String lastName;
	@Length(max = 128)
	private java.lang.String loginPwd;
	@NotBlank
	@Email
	@Length(max = 256)
	private java.lang.String loginEmail;

	private java.lang.Integer userType;

	private java.util.Date registerTime;

	private java.lang.Integer userStatus;

	// columns END

	public UserInfo() {
	}

	public UserInfo(Long userId) {
		this.userId = userId;
	}

	public void setUserId(Long value) {
		this.userId = value;
	}

	public Long getUserId() {
		return this.userId;
	}

	public void setLoginAccount(java.lang.String value) {
		this.loginAccount = value;
	}

	public java.lang.String getLoginAccount() {
		return this.loginAccount;
	}

	public void setUserName(java.lang.String value) {
		this.userName = value;
	}

	public java.lang.String getUserName() {
		return this.userName;
	}

	public void setFirstName(java.lang.String value) {
		this.firstName = value;
	}

	public java.lang.String getFirstName() {
		return this.firstName;
	}

	public void setLastName(java.lang.String value) {
		this.lastName = value;
	}

	public java.lang.String getLastName() {
		return this.lastName;
	}

	public void setLoginPwd(java.lang.String value) {
		this.loginPwd = value;
	}

	public java.lang.String getLoginPwd() {
		return this.loginPwd;
	}

	public void setLoginEmail(java.lang.String value) {
		this.loginEmail = value;
	}

	public java.lang.String getLoginEmail() {
		return this.loginEmail;
	}

	public void setUserType(java.lang.Integer value) {
		this.userType = value;
	}

	public java.lang.Integer getUserType() {
		return this.userType;
	}

	public String getRegisterTimeString() {
		return DateConvertUtils.format(getRegisterTime(), FORMAT_REGISTER_TIME);
	}

	public void setRegisterTimeString(String value) {
		setRegisterTime(DateConvertUtils.parse(value, FORMAT_REGISTER_TIME, java.util.Date.class));
	}

	public void setRegisterTime(java.util.Date value) {
		this.registerTime = value;
	}

	public java.util.Date getRegisterTime() {
		return this.registerTime;
	}

	public void setUserStatus(java.lang.Integer value) {
		this.userStatus = value;
	}

	public java.lang.Integer getUserStatus() {
		return this.userStatus;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("UserId", getUserId())
				.append("LoginAccount", getLoginAccount()).append("UserName", getUserName())
				.append("FirstName", getFirstName()).append("LastName", getLastName())
				.append("LoginPwd", getLoginPwd()).append("LoginEmail", getLoginEmail())
				.append("UserType", getUserType()).append("RegisterTime", getRegisterTime())
				.append("UserStatus", getUserStatus()).toString();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(getUserId()).toHashCode();
	}

	public boolean equals(Object obj) {
		if (obj instanceof UserInfo == false)
			return false;
		if (this == obj)
			return true;
		UserInfo other = (UserInfo) obj;
		return new EqualsBuilder().append(getUserId(), other.getUserId()).isEquals();
	}
}
